package com.example.thread;

//要加锁啰
public class TestRunnable2 implements Runnable{

    private int ticketNums = 10;

    @Override
    public void run() {
        while (true)
        {
            if (ticketNums<=0)
            {
                break;
            }
            System.out.println(Thread.currentThread().getName()+"拿到了第"+ticketNums+"张票");
        }
    }

    public static void main(String[] args) {
        TestRunnable testRunnable = new TestRunnable();
        new Thread(testRunnable,"小明").start();
        new Thread(testRunnable,"小红").start();
        new Thread(testRunnable,"小黑").start();
    }

}
